<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>首页</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />

<!-- easyui -->
<script type="text/javascript" th:src="@{/easyui/jquery.min.js}" ></script>
<script type="text/javascript" th:src="@{/easyui/jquery.easyui.min.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/default/easyui.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/icon.css}">
<link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/color.css}">
	<script type="text/javascript" th:src="@{/easyui/locale/easyui-lang-zh_CN.js}"></script>
</head>
<body>
	<input id="role" type="hidden" th:value="${session.role}"/>
	<div th:replace="commons/pub::#list"></div>
	<div id="stu_tool_bar">
		<a id="moreBtn" href="javascript:;" class="easyui-linkbutton">查看更多</a>
		<a id="passBtn" href="javascript:;" class="easyui-linkbutton">审核通过</a>
		<a id="unpassBtn" href="javascript:;" class="easyui-linkbutton">审核未通过</a>
	</div>
	<!-- 编辑窗口 -->
	<div id="win">
		<form id="editForm" method="post">
			实验编号：<input name="teId" type="number" class="easyui-validatebox" /><br>
			课程编号：<input name="teNo" class="easyui-validatebox" /><br>
			申请人编号：<input name="teAId" class="easyui-validatebox" /><br>
			实验标题:<input name="teTitle" class="easyui-validatebox" /><br>
			实验内容:<input name="teContent" class="easyui-validatebox" /><br>
			申请人姓名:<input name="teAName" class="easyui-validatebox" /><br>
			实验室编号:<input name="labId" class="easyui-validatebox" /><br>
			日期:<input name="teDate" class="easyui-validatebox" /><br>
			学院:<input name="teAcademy" class="easyui-validatebox" /><br>
			状态:<input name="laState" type="radio" class="easyui-validatebox" value="1"/>通过
			<input name="laState" type="radio" class="easyui-validatebox"  value="0"/>未通过
			<input name="laState" type="radio" class="easyui-validatebox"  value="2"/>待审核<br>
		</form>
	</div>
	<script type="text/javascript" th:inline="none">
	$(function(){
		var role=$("#role").val();
		$('#list').datagrid({   
		    url:'/tex/listByPage?',/*role=+role*/
		    columns:[[
				{field:'id',title:'编号',checkbox:true},
				{field:'teId',title:'实验编号',width:'10%',align:'center'},
				{field:'teNo',title:'课程编号',width:'20%',align:'center'},
				{field:'teTitle',title:'实验标题',width:'20%',align:'center'},
				{field:'teAName',title:'申请人姓名',width:'30%',align:'center'},
				{field:'laState',title:'状态',width:'10%',align:'center'}
		    ]],
		    pagination:true,
		    toolbar:"#stu_tool_bar"
		}); 
		$('#win').window({
		    width:600,   
		    height:400, 
		    padding:30,
		    closed:true,
		    title:"开放性实验信息表",
		    modal:true  
		});
		//查看更多
		$("#moreBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length!=1){
				$.messager.alert("提示","修改操作只能选择一行","warning");
				return;
			}
			//表单回显
			$("#editForm").form("load","/tex/findTexById?teId="+rows[0].teId+"");
			$("#editForm input").attr("disabled","disabled");
			$("#win").window("open");
		});
		//审核通过
		$("#passBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length==0){
				$.messager.alert("提示","审核通过操作至少选择一行","warning");
				return;
			}
			$.messager.confirm("提示","确定审核通过吗？",function(value){
				if(value){
					var idStr= "";
					$(rows).each(function(i){
						idStr+=("oeId="+rows[i].teId);
						if(i!=$(rows).length-1){
							idStr+="&";
						}
					});
					$.post("/tex/passTexperiment",idStr,function(data){
						if(data.success){
							$("#list").datagrid("reload");
							$.messager.alert("提示","审核通过成功!","info");
						}else{
							$.messager.alert("提示","审核通过失败!",data.msg,"error");
						}
					},"json");
				}
			});
		});
		$("#unpassBtn").click(function(){
			//判断只能选择一行
			var rows=$("#list").datagrid("getSelections");
			if(rows.length==0){
				$.messager.alert("提示","审核未通过操作至少选择一行","warning");
				return;
			}
			$.messager.confirm("提示","确定审核未通过吗？",function(value){
				if(value){
					var idStr= "";
					$(rows).each(function(i){
						idStr+=("teId="+rows[i].teId);
						if(i!=$(rows).length-1){
							idStr+="&";
						}
					});
					$.post("/tex/unpassTexperiment",idStr,function(data){
						if(data.success){
							$("#list").datagrid("reload");
							$.messager.alert("提示","审核未通过成功!","info");
						}else{
							$.messager.alert("提示","审核未通过失败!",data.msg,"error");
						}
					},"json");
				}
			});
		});
	});
	</script>

</body>